/**
 * author:Administrator
 * date:2016/1/4
 * desc:TODO
 */

'use strict';

var Router = require('koa-router');
var bodyParser = require('koa-better-body');

var __pathPrefix = '/coupon';
var router = new Router({prefix: __pathPrefix});
module.exports = router.routes();

var biz = require('../biz/coupon.js');
/**
 * post /coupon/application
 {
   "cvid": 123,
   "uid": 111,
   "qty": 11,
   "cond": "aa"
 }
 */
router.post('/application', function*() {
  var json = {
    cvid: this.request.inParams.fields.cvid,
    uid: this.request.inParams.fields.uid,
    qty: this.request.inParams.fields.qty,
    cond: this.request.inParams.fields.cond
  };
  //console.log(json);
  var retObj = yield biz.userApplyCoupon(json);
  if (retObj.errcode != 0) {
    console.log(retObj);
  }
  this.body = retObj;
});